package czx.wt.system.service.impl;

import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import czx.wt.system.mapper.AuthoritiesMapper;
import czx.wt.system.pojo.Authorities;
import czx.wt.system.service.IAuthoritiesService;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author: ChenZhiXiang
 * @Date: 2019/6/19 23:22
 * @Description: 权限实现层
 */
@Service
public class AuthoritiesServiceImpl extends ServiceImpl<AuthoritiesMapper, Authorities> implements IAuthoritiesService {

    @Override
    public List<String> getAuthoritiesByUserId(Integer userId) {
        
        return baseMapper.getAuthoritiesByUserId(userId);
    }

    @Override
    public List<String> getAuthoritiesByRoleId(List<Integer> roleIds) {
        if (roleIds == null || roleIds.size() ==0){
            return new ArrayList<>();
        }
        return baseMapper.getAuthoritiesByRoleId(roleIds);
    }

    @Override
    public List<String> getAuthoritiesListByRoleId(Integer roleId) {
        List<Integer> roleIds = new ArrayList<>();
        if (roleId != null){
            roleIds.add(roleId);
        }
        return getAuthoritiesByRoleId(roleIds);
    }
}
